package com.bier.fishproject.adapter;

import com.bier.fishproject.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class BillHeadAdapter extends BaseAdapter{
	
	private Context context;
	private String[] str;
	public int index;
	public BillHeadAdapter(Context context,String[] str) {
		super();
		this.context = context;
		this.str=str;
	}

	@Override
	public int getCount() {
		return str==null ? 0 : str.length;
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder holder = null;
		if(view==null){
			holder = new ViewHolder(); 
			view = LayoutInflater.from(context).inflate(R.layout.billhead_item, null);
			holder.tvName=(TextView)view.findViewById(R.id.tv_bi_name);
			holder.view=(View)view.findViewById(R.id.view_bi);
			view.setTag(holder);
		}else{
			holder=(ViewHolder)view.getTag();
		}
		holder.tvName.setText(str[position]);
		if(index==position){
			holder.tvName.setTextColor(context.getResources().getColor(R.color.main_color));
			holder.view.setBackgroundColor(context.getResources().getColor(R.color.main_color));
		}else{
			holder.view.setBackgroundColor(context.getResources().getColor(android.R.color.white));
			holder.tvName.setTextColor(context.getResources().getColor(R.color.shen_gray));
		}
		return view;
	}
	
	private class ViewHolder{
		private TextView tvName;
		private View view;
	 }

}
